home *** CD-ROM | disk | FTP | other *** search
/ Clickx 47 / Clickx 47.iso / assets / software / sswitchxp152.exe / source / SpeedswitchXP / Cpuid.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-05-03  |  6.3 KB  |  211 lines

  1. /***************************************************************
  2. * H file: cpuid.h... for cpuinf32 DLL
  3. *
  4. *   This program has been developed by Intel Corporation.  
  5. *        You have Intel's permission to incorporate this code 
  6. *   into your product, royalty free.
  7. *
  8. *  Copyright (c) 1995, Intel Corporation.  All rights reserved.
  9. *
  10. *  Runtime optimizations & modifications for SpeedswitchXP 
  11. *    by C. Diefer
  12. ***************************************************************/
  13.  
  14.  
  15. #ifndef cpuid_h
  16. #define cpuid_h
  17.  
  18.  
  19.  
  20. // OPCODE DEFINITIONS //////////////////////////////////////////
  21. #define CPU_ID _asm _emit 0x0f _asm _emit 0xa2  
  22.                                         // CPUID instruction
  23.  
  24. #define RDTSC  _asm _emit 0x0f _asm _emit 0x31  
  25.                                         // RDTSC instruction
  26.  
  27.  
  28. // VARIABLE STRUCTURE DEFINITIONS //////////////////////////////
  29. struct TIME_STAMP
  30. {
  31.     DWORD High;                 // Upper 32-bits of Time Stamp
  32.                                 //   Register value
  33.     
  34.     DWORD Low;                  // Lower 32-bits of Time Stamp
  35. };                              //   Register value
  36.  
  37. // extern BYTE vendor_id[16];
  38. // extern DWORD family;
  39. // extern DWORD maxIDVal;
  40. // extern DWORD cpuffext;
  41. // extern DWORD brandid;
  42.  
  43. // Function Prototypes /////////////////////////////////////////
  44.  
  45. /***************************************************************
  46. * WORD wincpuidsupport()
  47. * =================================
  48. * Wincpuidsupport() tells the caller whether the host processor
  49. * supports the CPUID opcode or not.
  50. *
  51. * Inputs: none
  52. *
  53. * Returns:
  54. *  1 = CPUID opcode is supported
  55. *  0 = CPUID opcode is not supported
  56. ***************************************************************/
  57.  
  58. WORD wincpuidsupport();
  59.  
  60.  
  61. /***************************************************************
  62. * WORD wincpuid()
  63. * ===============
  64. * This routine uses the standard Intel assembly code to 
  65. * determine what type of processor is in the computer, as
  66. * described in application note AP-485 (Intel Order #241618).
  67. * Wincpuid() returns the CPU type as an integer (that is, 
  68. * 2 bytes, a WORD) in the AX register.
  69. *
  70. * Returns:
  71. *  0 = 8086/88
  72. *  2 = 80286
  73. *  3 = 80386
  74. *  4 = 80486
  75. *  5 = Pentium(R) Processor
  76. *  6 = PentiumPro(R) Processor
  77. *  7 or higher = Processor beyond the PentiumPro6(R) Processor
  78. *
  79. *  Note: This function also sets the global variable clone_flag
  80. ***************************************************************/
  81. WORD  wincpuid();
  82.  
  83.  
  84. /***************************************************************
  85. * DWORD wincpufeatures()
  86. * ======================
  87. * Wincpufeatures() returns the CPU features flags as a DWORD 
  88. *    (that is, 32 bits).
  89. *
  90. * Inputs: none
  91. *
  92. * Returns:
  93. *   0 = Processor which does not execute the CPUID instruction.
  94. *          This includes 8086, 8088, 80286, 80386, and some 
  95. *          older 80486 processors.                       
  96. *
  97. * Else
  98. *   Feature Flags (refer to App Note AP-485 for description).
  99. *      This DWORD was put into EDX by the CPUID instruction.
  100. *
  101. *   Current flag assignment is as follows:
  102. *
  103. *       bit31..10   reserved (=0)
  104. *       bit9=1      CPU contains a local APIC (iPentium-3V)
  105. *       bit8=1      CMPXCHG8B instruction supported
  106. *       bit7=1      machine check exception supported
  107. *       bit6=0      reserved (36bit-addressing & 2MB-paging)
  108. *       bit5=1      iPentium-style MSRs supported
  109. *       bit4=1      time stamp counter TSC supported
  110. *       bit3=1      page size extensions supported
  111. *       bit2=1      I/O breakpoints supported
  112. *       bit1=1      enhanced virtual 8086 mode supported
  113. *       bit0=1      CPU contains a floating-point unit (FPU)
  114. *
  115. *   Note: New bits will be assigned on future processors... see
  116. *         processor data books for updated information
  117. *
  118. *   Note: This function also sets the global variable clone_flag
  119. ***************************************************************/
  120. DWORD wincpufeatures();
  121.  
  122.  
  123. /***************************************************************
  124. * struct TIME_STAMP winrdtsc()
  125. * ============================
  126. * Winrdtsc() returns the value in the Time Stamp Counter (if one
  127. * exists).
  128. *
  129. * Inputs: none
  130. *
  131. * Returns:
  132. *   0 = CPU does not support the time stamp register
  133. *
  134. * Else
  135. *   Returns a variable of type TIME_STAMP which is composed of 
  136. *      two DWORD variables. The 'High' DWORD contains the upper
  137. *      32-bits of the Time Stamp Register. The 'Low' DWORD 
  138. *      contains the lower 32-bits of the Time Stamp Register.
  139. *
  140. *  Note: This function also sets the global variable clone_flag
  141. ***************************************************************/
  142. struct TIME_STAMP winrdtsc();
  143.  
  144.  
  145. // Private Function Declarations ///////////////////////////////
  146.  
  147. /***************************************************************
  148. * static WORD check_clone()
  149. *
  150. * Inputs: none
  151. *
  152. * Returns:
  153. *   1      if processor is clone (limited detection ability)
  154. *   0      otherwise
  155. ***************************************************************/
  156. static WORD check_clone();
  157.  
  158.  
  159. /***************************************************************
  160. * static WORD check_8086()
  161. *
  162. * Inputs: none
  163. *
  164. * Returns: 
  165. *   0      if processor 8086
  166. *   0xffff otherwise
  167. ***************************************************************/
  168. static WORD check_8086();
  169.  
  170.  
  171. /***************************************************************
  172. * static WORD check_80286()
  173. *
  174. * Inputs: none
  175. *
  176. * Returns:
  177. *   2      if processor 80286
  178. *   0xffff otherwise
  179. ***************************************************************/
  180. static WORD check_80286();
  181.  
  182.  
  183. /***************************************************************
  184. * static WORD check_80386()
  185. *
  186. * Inputs: none
  187. *
  188. * Returns:
  189. *   3      if processor 80386
  190. *   0xffff otherwise
  191. ***************************************************************/
  192. static WORD check_80386();
  193.  
  194.  
  195. /***************************************************************
  196. * static WORD check_IDProc()
  197. * ==========================
  198. * Check_IDProc() uses the CPUID opcode to find the family type
  199. * of the host processor.
  200. *
  201. * Inputs: none
  202. *
  203. * Returns:
  204. *  CPU Family (i.e. 4 if Intel 486, 5 if Pentium(R) Processor)
  205. *
  206. *  Note: This function also sets the global variable clone_flag
  207. ***************************************************************/
  208. static WORD check_IDProc();
  209.  
  210. #endif cpuid_h
  211.